﻿using UnityEngine;
using System.Collections;

public class UnitAnimations : MonoBehaviour {

    public exSpriteAnimation target;
    bool front;

    public void Play(string prefix, bool front)
    {
        this.front = front;
        Play(prefix);
    }

    public void Play(string prefix)
    {
        var clip = prefix + (front ? "_front" : "_back");
        if (!target.IsPlaying(clip))
            target.Play(clip);
    }

    public void Move(bool front)
    {
        Play("walk", front);
    }

    public void Idle()
    {
        Play("idle");
    }

    public void Idle(bool front)
    {
        Play("idle", front);
    }
}
